import sys
from pylab import *

def compute_points(svm_res):
    x_s=arange(-1,1,0.01)
    a = 0 ; c = 0
    b = svm_res['bias']
    for sv,alpha in zip(svm_res['sv_s'],svm_res['alpha_s']):
        a += alpha*sv[1]
        c += alpha*sv[2]
    print a,b,c
    y_s = []
    for x in x_s:
        y_s.append(-(a*x)/c)

    return x_s,y_s

def draw(c_s, point_s, svm_res):
    t = compute_points(svm_res)
    plot(t[0],t[1])
    for c,point in zip(c_s,point_s):
        if c>0:    
            scatter(point[1],point[2],c='b')
        else:
            scatter(point[1],point[2],c='y')

    for sv,alpha in zip(svm_res['sv_s'],svm_res['alpha_s']):
        if alpha>0:
            scatter(sv[1],sv[2],c='r',marker='o')
        else:
            scatter(sv[1],sv[2],c='g',marker='o')
    show()
